package com.lightMS.agenda.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;

public class DatabaseAdapter {
	private static SQLiteDatabase db = null;
	
	public static SQLiteDatabase open (Context context){
		if (db == null) {
			DatabaseHelper dbHelper = new DatabaseHelper(context);
			try {
				db = dbHelper.getWritableDatabase();
			} catch (SQLiteException ex) {
				db = dbHelper.getReadableDatabase();
			}
		}
		return db;
	}
	
	public void close() {
		db.close();
	}
}